//-------------------------------------------------------------------
//	Copyright (c) 2010-2014  Zhirnov Andrey
//	This file is part of the "UX Standard Lib" project.
//	See copyright notice in "UX_STL_Ext.h".
//-------------------------------------------------------------------

#ifndef _UXS_GL_DEFAULT_RENDER_H
#define _UXS_GL_DEFAULT_RENDER_H

#pragma once

#include "GLSystem.h"
#include "../../OS/OS.h"


namespace UX_STL
{
namespace GLShell
{


	//
	// Default OpenGL Render
	//

	class UX_EXPORT GLDefaultRender : public GLSystem, public IWindowEventListener
	{
	protected:
		GLObjectManager			_cObjMan;
		GLViewport				_cDefViewport;
		Ptr< GLWindow >			_pCurWindow;
		Ptr< GLViewport >		_pViewport;

	protected:
		virtual void ProcessMessage(const TWindowEvent &sEvent);

	public:
		GLDefaultRender();
		~GLDefaultRender();

		bool  Init (GLWindow *pWnd);
		void  Destroy();

		void  SetViewport(GLViewport *pVP);
		void  Mode2D(bool bFlipY = false);
		void  Setup2DMode(const frect &sViewRect, const fvec2 &vClipPlanes = fvec2(-1.f,1.f));

		GLBatchRender *	BatchRender()	{ return &_cBatchRender; }
		GLViewport *	Viewport()		{ return _pViewport; }
	};



/*
=================================================
	
=================================================
*/
	inline void GLDefaultRender::SetViewport(GLViewport *pVP)
	{
		_pViewport = pVP;
	}

/*
=================================================
	
=================================================
*/
	inline void GLDefaultRender::Mode2D(bool bFlipY)
	{
		Viewport()->_Mode2D( bFlipY );
	}
	
/*
=================================================
	
=================================================
*/
	inline void GLDefaultRender::Setup2DMode(const frect &sViewRect, const fvec2 &vClipPlanes)
	{
		Viewport()->_Setup2DMode( sViewRect, vClipPlanes );
	}


}	// GLShell
}	// UX_STL

#endif	// _UXS_GL_DEFAULT_RENDER_H